import request from '@/utils/request'

// 工作经历
export interface Experience {
  id?: number
  company: string
  position: string
  startDate: string
  endDate: string
  empId?: number
}

// 员工信息
export interface Employee {
  id?: number
  username: string
  name: string
  gender: number
  image: string
  position: number
  salary: number
  hireDate: string
  deptId: number
  deptName?: string
  phone?: string
  createTime?: string
  updateTime?: string
  exprList?: Experience[]
}

// 查询参数
export interface EmpQuery {
  name?: string
  gender?: number
  begin?: string
  end?: string
  page: number
  pageSize: number
}

// 分页结果
export interface PageResult<T> {
  total: number
  rows: T[]
}

// 获取员工列表
export function getEmpList(params: EmpQuery) {
  return request.get<PageResult<Employee>>('/emps', params)
}

// 删除员工
export function deleteEmps(ids: string) {
  return request.delete(`/emps?ids=${ids}`)
}

// 添加员工
export function addEmp(data: Employee) {
  return request.post('/emps', data)
}

// 根据ID查询员工
export function getEmpById(id: number) {
  return request.get<Employee>(`/emps/${id}`)
}

// 修改员工
export function updateEmp(data: Employee) {
  return request.put('/emps', data)
}
